package guiservice.server.controls;

import lombok.extern.log4j.Log4j;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

@Log4j
public class TextBox extends Control implements guiservice.common.controls.TextBox {

    private JTextField textBox;

    public TextBox(long id, long owner) {
        super(id, owner, guiservice.common.controls.TextBox.class.getCanonicalName());
        textBox = new JTextField();
        textBox.setFont(new Font("Calibry", 0, 12));
    }

    protected Component getComponent() {
        return textBox;
    }

    @Override
    public String getText() {
        String text = textBox.getText();
        log.debug(String.format("id=%d get text=%s", id, text));
        return text;
    }

    @Override
    public void setText(String text) {
        log.debug(String.format("id=%d set text=%s", id, text));
        textBox.setText(text);
    }

}
